function [vl_lwin1,vh_lwin1,vl_llose1,vh_llose1,p_lwin1,p_llose1]=transition_prob_stage1(parameter,tpORtp3h,Cpm25,parameter_fixed,c_l,c_h,V_l,V_h)


N=size(c_l,1);

% Parameters that are fixed
cutoff_tp=parameter_fixed(1);
cutoff_pm=parameter_fixed(2);
delta_0  =parameter_fixed(3);

% Parameters that are estimated
k       =parameter(1);
delta_tp=parameter(3);
delta_pm=parameter(4);

% Delta shifts when temperature or PM2.5 separately exceed thresholds
delta = repmat(delta_0,N,1) + delta_tp * ( tpORtp3h > cutoff_tp ) + delta_pm * ( Cpm25 > cutoff_pm );


% Call on transition_prob_stage2: these are continuation values (in stage 2) conditional on stage-1 outcome
[vl_lwin2_lwon1,vh_lwin2_lwon1,vl_llose2_lwon1,vh_llose2_lwon1,vl_lwin2_llost1,vh_lwin2_llost1,vl_llose2_llost1,vh_llose2_llost1,p_lwin2_lwon1,p_llose2_lwon1,p_lwin2_llost1,p_llose2_llost1]=transition_prob_stage2(parameter,tpORtp3h,Cpm25,parameter_fixed,c_l,c_h,V_l,V_h);

% Conditional on lwon1
spread_l=vl_lwin2_lwon1-vl_llose2_lwon1;                    % Player l's stage-2 win/lose payoff spread, conditional on lwon1
spread_h=vh_llose2_lwon1-vh_lwin2_lwon1;                    % Player h's stage-2 win/lose payoff spread, conditional on lwon1
% Equilibrium effort costs incurred in stage 2: Different across players given different win/lose payoffs spreads in stage 2
effortcostl_stage2=k*spread_l.*( ((c_l./c_h).*(spread_h./spread_l)).^k ) ./ ( (ones(N,1)+((c_l./c_h).*(spread_h./spread_l)).^k).^2 );
effortcosth_stage2=k*spread_h.*( ((c_h./c_l).*(spread_l./spread_h)).^k ) ./ ( (ones(N,1)+((c_h./c_l).*(spread_l./spread_h)).^k).^2 );
    % CORNER: If vh_llose2_lwon1<=0 <=> spread_h<=0, then battle-1 loser (player h in this case) throws the towel in battle 2: it is best to not exert effort, finish 2-0 and secure CV=0, than to try to transition to 1-1 with CV<0
    effortcostl_stage2=effortcostl_stage2.*(vh_llose2_lwon1>0);
    effortcosth_stage2=effortcosth_stage2.*(vh_llose2_lwon1>0);
    zero_spread_h=(spread_h==0);                 % Need to handle division by spread_h=0, which returned NaN
    effortcosth_stage2(zero_spread_h)=0;

% lwin1
vl_lwin1=p_lwin2_lwon1.*vl_lwin2_lwon1 + p_llose2_lwon1.*vl_llose2_lwon1 - effortcostl_stage2 - delta;   % Continuation values (in stage 2) conditional on stage-1 outcome lwin1
vh_lwin1=p_lwin2_lwon1.*vh_lwin2_lwon1 + p_llose2_lwon1.*vh_llose2_lwon1 - effortcosth_stage2 - delta;
clear spread_l spread_h effortcostl_stage2 effortcosth_stage2 zero_spread_h;

% Conditional on llost1
spread_l=vl_lwin2_llost1-vl_llose2_llost1;                  % Player l's stage-2 win/lose payoff spread, conditional on llost1
spread_h=vh_llose2_llost1-vh_lwin2_llost1;                  % Player h's stage-2 win/lose payoff spread, conditional on llost1
% Equilibrium effort costs incurred in stage 2: Different across players given different win/lose payoffs spreads in stage 2
effortcostl_stage2=k*spread_l.*( ((c_l./c_h).*(spread_h./spread_l)).^k ) ./ ( (ones(N,1)+((c_l./c_h).*(spread_h./spread_l)).^k).^2 );
effortcosth_stage2=k*spread_h.*( ((c_h./c_l).*(spread_l./spread_h)).^k ) ./ ( (ones(N,1)+((c_h./c_l).*(spread_l./spread_h)).^k).^2 );
    % CORNER: If vl_lwin2_llost1<=0 <=> spread_l<=0, then battle-1 loser (player l in this case) throws the towel in battle 2: it is best to not exert effort, finish 0-2 and secure CV=0, than to try to transition to 1-1 with CV<0
    effortcostl_stage2=effortcostl_stage2.*(vl_lwin2_llost1>0);
    effortcosth_stage2=effortcosth_stage2.*(vl_lwin2_llost1>0);
    zero_spread_l=(spread_l==0);                 % Need to handle division by spread_l=0, which returned NaN 
    effortcostl_stage2(zero_spread_l)=0;

% llose1
vl_llose1=p_lwin2_llost1.*vl_lwin2_llost1 + p_llose2_llost1.*vl_llose2_llost1 - effortcostl_stage2 - delta; % Again, continuation values (in stage 2) conditional on stage-1 outcome llose1
vh_llose1=p_lwin2_llost1.*vh_lwin2_llost1 + p_llose2_llost1.*vh_llose2_llost1 - effortcosth_stage2 - delta;
clear spread_l spread_h effortcostl_stage2 effortcosth_stage2 zero_spread_l;

spread_l=vl_lwin1 -vl_llose1;                          % Player l's stage-1 win/lose payoff spread
spread_h=vh_llose1-vh_lwin1;                           % Player h's stage-1 win/lose payoff spread
% Equilibrium effort costs incurred in stage 1: Equal across symmetric players given equal win/lose payoff spreads in stage 1
effortcostl_stage1=k*spread_l.*( ((c_l./c_h).*(spread_h./spread_l)).^k ) ./ ( (ones(N,1)+((c_l./c_h).*(spread_h./spread_l)).^k).^2 );
effortcosth_stage1=k*spread_h.*( ((c_h./c_l).*(spread_l./spread_h)).^k ) ./ ( (ones(N,1)+((c_h./c_l).*(spread_l./spread_h)).^k).^2 );
    % CORNER: If spread_h<=0, then player h throws the towel already in battle 1: it is best not to exert effort already in battle 1, since CV at 1-0 is less negative than the CV at 0-1
    effortcostl_stage1=effortcostl_stage1.*(spread_h>0);
    effortcosth_stage1=effortcosth_stage1.*(spread_h>0);
    zero_spread_h=(spread_h==0);                 % Need to handle division by spread_h=0, which returned NaN
    effortcosth_stage1(zero_spread_h)=0;
% Divide a player's equilibrium effort cost by marginal cost to obtain effort choice; lambda=1
xl1=effortcostl_stage1./c_l;
xh1=effortcosth_stage1./c_h;
% Transition probabilities   
p_lwin1 = xl1.^k ./ (xl1.^k + xh1.^k);
% Can subsequently call on transition_prob_oneshot to speed up; as well as comment out the clear commands?
%p_lwin1=ones(N,1)./(ones(N,1)+(c_l./c_h.*spread_h./spread_l).^k);
%p_lwin1=transition_prob_oneshot(c_l,c_h,spread_l,spread_h,k);
    % CORNER
    p_lwin1(xl1==0)=1;              % In battle 1, player l exerts infinitesimally positive effort and wins over player h who exerts 0 effort
p_llose1=ones(N,1)-p_lwin1;
clear spread_l spread_h effortcostl_stage1 effortcosth_stage1 zero_spread_h;

end